package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据主键查询菜品
     *
     * @param dishIds
     * @return
     */
    // select setmeal_id from setmeal_dish where dish_id in （1，2，3）
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);


    /**
     * 根据菜品ID删除对应口味数据
     *
     * @param dishId
     */
    @Delete("delete from dish_flavor where dish_id =#{dishId}")
    void deleteById(Long dishId);

    /**
     * 向套餐菜品表批量插入菜品数据
     *
     * @param dishes
     */
    @AutoFill(OperationType.INSERT)
    void insertBatch(List<SetmealDish> dishes);

    /**
     * 批量删除
     */
    void deleteByIds(List<Long> setmealIds);

    /**
     * 根据套餐id查询菜品
     * @param id
     * @return
     */
    List<SetmealDish> getBySetmealId(Long id);

}
